package cn.afterturn.easypoi.test.excel.export;

import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.test.entity.StudentEntity;
import cn.afterturn.easypoi.test.entity.StudentHiderEntity;
import org.apache.poi.ss.usermodel.Workbook;
import org.junit.Test;

import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 隐藏列测试 Created by jueyue on 18-1-26.
 */
public class ExcelExportHideCol {

	@Test
	public void testStudentList() throws Exception {
		Date start = new Date();
		StudentHiderEntity studentEntity = new StudentHiderEntity();
		studentEntity.setId("11231");
		studentEntity.setName("撒旦法司法局");
		studentEntity.setBirthday(new Date());
		studentEntity.setRegistrationDate(new Date());
		studentEntity.setSex(2);
		List<StudentHiderEntity> studentList = new ArrayList<StudentHiderEntity>();
		studentList.add(studentEntity);
		studentList.add(studentEntity);
		// start:******************************************************/
		// 在bean的字段属性 设置 isColumnHidden = true 隐藏列，在输出的excel中不显示 ;isColumnHidden
		// = false 则在输出的excel中显示
		// end:******************************************************/
		Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("计算机一班学生", "学生"), StudentHiderEntity.class, studentList);
		System.out.println(new Date().getTime() - start.getTime());
		File savefile = new File("c:/excelllllllll/");
		if (!savefile.exists()) {
			savefile.mkdirs();
		}
		FileOutputStream fos = new FileOutputStream("c:/excelllllllll/ExcelExportHideCol.xls");
		workbook.write(fos);
		fos.close();
	}

}
